import QtQuick 2.0

Item {
    id: noteMenu
    property Item note: parent
    property string url: "images/unpinnedGreen.png"
    //property int iconSize: 40
    //property int iconSpacing: 10
    anchors.fill: parent

    Image {
        source: url
        height: 30
        fillMode: Image.PreserveAspectFit
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.topMargin: 10
        anchors.leftMargin: 20

        MouseArea {
            anchors.fill: parent
            onClicked: togglePin()
        }
    }

    Image {
        source: "images/binBlack.png"
        height: 30
        fillMode: Image.PreserveAspectFit
        anchors.top: parent.top
        anchors.right: parent.right
        anchors.topMargin: 10
        anchors.rightMargin: 10

        MouseArea {
            anchors.fill: parent
            onClicked: note.destroy()
        }
    }

    function togglePin() {
        note.isPinned = !note.isPinned
        var pos

        if (note.isPinned) {
            pos = note.mapToItem(myKit, note.x, note.y)
            pos.x -= note.x
            pos.y -= note.y
            note.parent = myKit

            url = "images/pinnedGreen.png"
        } else {
            pos = note.mapToItem(stickyContent, note.x, note.y)
            pos.x -= note.x
            pos.y -= note.y
            note.parent = stickyContent
            url = "images/unpinnedGreen.png"
        }

        note.x = pos.x
        note.y = pos.y
    }
}
